﻿#region Copyright(c) 2006 ZO, All right reserved.
// -----------------------------------------------------------------------------
// Copyright(c) 2006 ZO, All right reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//   1.  Redistribution of source code must retain the above copyright notice,
//       this list of conditions and the following disclaimer.
//   2.  Redistribution in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//   3.  The name of the author may not be used to endorse or promote products
//       derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
#endregion


#region Using directives

using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Security.Permissions;
using System.Windows.Forms;
using ZO.SmartCore.Threading;

#endregion

namespace ZO.SmartCore.My4CSharp
{
    /// <summary>
    /// Provides properties for manipulating computer components such as audio, the clock, the keyboard, the file system, and so on.
    /// </summary>
    [Browsable(false)]
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    [HostProtection(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
    public class Computer
    {

        #region Constructors

        #endregion

        #region Destructor

        #endregion

        #region Fields
        private static readonly ThreadSafeObjectProvider<Clipboard> _Clipboard = new ThreadSafeObjectProvider<Clipboard>();
        private static readonly ThreadSafeObjectProvider<Network> _Network = new ThreadSafeObjectProvider<Network>();
        private static readonly ThreadSafeObjectProvider<FileSystem> _FileSystem = new ThreadSafeObjectProvider<FileSystem>();
        private static readonly ThreadSafeObjectProvider<ComputerInfo> _Info = new ThreadSafeObjectProvider<ComputerInfo>();
        private static readonly ThreadSafeObjectProvider<Ports> _Ports = new ThreadSafeObjectProvider<Ports>();
        private static readonly ThreadSafeObjectProvider<Mouse> _Mouse = new ThreadSafeObjectProvider<Mouse>();
        private static readonly ThreadSafeObjectProvider<Keyboard> _Keyboard = new ThreadSafeObjectProvider<Keyboard>();
        private static readonly ThreadSafeObjectProvider<Audio> _Audio = new ThreadSafeObjectProvider<Audio>();
        private static readonly ThreadSafeObjectProvider<Clock> _Clock = new ThreadSafeObjectProvider<Clock>();
        
        #endregion

        #region Events

        #endregion

        #region Operators

        #endregion

        #region Properties

        /// <summary>
        /// Provides properties for getting information about the computer's memory, loaded assemblies, name, and operating system..
        /// </summary>
        public ComputerInfo Info
        {
            get
            {
                return _Info.Instance;
            } // get
        } // Info

        /// <summary>Gets an object that provides methods for manipulating the Clipboard.</summary>
        /// <returns>This property returns the Clipboard Object for the computer.</returns>
        public Clipboard Clipboard
        {
            get
            {
                return _Clipboard.Instance;
            }
        }


        /// <summary>
        /// Gets an object that Provides a property, event, and methods for interacting with the network to which the computer is connected.
        /// </summary>
        public Network Network
        {
            get
            {
                return _Network.Instance;
            } // get
        } // Network

        /// <summary>Gets the computer name.</summary>
        /// <returns>A String containing the name of the computer.</returns>
        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public string Name
        {
            get
            {
                return Environment.MachineName;
            } // get
        } // Name


        /// <summary>
        /// Gets an object that provides properties and methods for working with drives, files, and directories. 
        /// </summary>
        public FileSystem FileSystem
        {
            get
            {
                return _FileSystem.Instance;
            } // get
        } // FileSystem


        /// <summary>Gets the <see cref="T:System.Windows.Forms.Screen"></see> object that represents the computer's primary display screen.</summary>
        /// <returns>A <see cref="T:System.Windows.Forms.Screen"></see> object that represents the computer's primary screen.</returns>
        public Screen Screen
        {
            get
            {
                return Screen.PrimaryScreen;
            }
        }
        /// <summary>Gets an object that provides a property and a method for accessing the computer's serial ports.</summary>
        /// <returns>This property returns the My.Computer.Ports object.</returns>
        public Ports Ports
        {
            get
            {
                return _Ports.Instance;
            }
        }

        /// <summary>Gets an object that provides properties for getting information about the format and configuration of the mouse installed on the local computer.</summary>
        /// <returns>This property returns the My.Computer.Mouse object for the computer.</returns>
        public Mouse Mouse
        {
            get
            {
                return _Mouse.Instance;
            }
        }

        /// <summary>Gets an object that provides properties for accessing the current state of the keyboard, such as what keys are currently pressed, and provides a method to send keystrokes to the active window.</summary>
        /// <returns>This property returns the My.Computer.Keyboard object for the computer.</returns>
        public Keyboard Keyboard
        {
            get
            {
                return _Keyboard.Instance;
            }
        }

        /// <summary>Gets an object that provides properties for methods for playing sounds.</summary>
        /// <returns>This property returns the My.Computer.Audio object for the computer.</returns>
        public Audio Audio
        {
            get
            {
                return _Audio.Instance;
            }
        }

        /// <summary>Gets an object that provides properties for accessing the current local time and Universal Coordinated Time (the equivalent to Greenwich Mean Time) from the system clock.</summary>
        /// <returns>This property returns the My.Computer.Clock object for the computer.</returns>
        public Clock Clock
        {
            get
            {
                return _Clock.Instance;
            }
        }
 


        #endregion

        #region Methods

        #endregion
    }
}
